﻿Public Class frmStudentInfoQuery

    Private Sub frmStudentInfoQuery_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim icount As Integer
        cboWhere.Items.Clear()
        cboWhere.Items.Add("学号")
        cboWhere.Items.Add("姓名")
        cboWhere.Items.Add("专业")
        cboWhere.SelectedIndex = 0
        txtSQL = "SELECT 学号,姓名,性别,出生日期,籍贯,少数民族否,入学成绩,专业名称,简历,主页 FROM 学生"
        icount = ExecuteSQL(txtSQL, ErrorMsg)
        DataGridView1.DataSource = DBSet.Tables.Item(0)
    End Sub

    Private Sub cmdQuery_Click(sender As Object, e As EventArgs) Handles cmdQuery.Click
        If Trim(txtWord.Text) = "" Then
            MsgBox("请输入检索词")
            Exit Sub
        End If
        txtSQL = "SELECT 学号,姓名,性别,出生日期,籍贯,少数民族否,入学成绩,专业名称,简历,主页 FROM 学生"
        If cboWhere.Text = "学号" Then
            txtSQL = txtSQL & " WHERE 学号='" & Trim(txtWord.Text) & "'"
        End If
        If cboWhere.Text = "姓名" Then
            txtSQL = txtSQL & " WHERE 姓名='" & Trim(txtWord.Text) & "'"
        End If
        If cboWhere.Text = "专业" Then
            txtSQL = txtSQL & " WHERE 专业名称='" & Trim(txtWord.Text) & "'"
        End If
        Dim icount As Integer
        icount = ExecuteSQL(txtSQL, ErrorMsg)
        DataGridView1.DataSource = DBSet.Tables.Item(0)
    End Sub

    Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub
End Class